// PropPageSetting1.cpp : 实现文件
//

#include "stdafx.h"
#include "SplitDemo.h"
#include "PropPageSetting1.h"
#include "afxdialogex.h"
#include "include/json/json.h"
#include <fstream>
#include <string>
#include "SplitDemo.h"
#include "PropSheetSetting.h"
#include "DeviceAddDla.h"
#include "MainFrm.h"
// CPropPageSetting1 对话框



// 
 #ifdef _DEBUG
// #ifndef _WIN64
 #pragma comment(lib,"json_vc71_libmtd.lib")
 //#else
 //#pragma comment(lib,"son_mtd_x64.lib")
 //#endif
 #else
// #ifndef _WIN64
 #pragma comment(lib,"json_vc71_libmt.lib")
// #else
// #pragma comment(lib,"json/json_mt_x64.lib")
// #endif
 #endif
using namespace std;
IMPLEMENT_DYNAMIC(CPropPageSetting1, CPropertyPage)

CPropPageSetting1::CPropPageSetting1()
	: CPropertyPage(CPropPageSetting1::IDD)
{
	m_psp.dwFlags = m_psp.dwFlags | PSP_USETITLE;
	m_psp.pszTitle = _T("Page1");
	m_nSelItem = 0xffffffff;
}

CPropPageSetting1::~CPropPageSetting1()
{
}

void CPropPageSetting1::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_DEVICE_LIST, m_DevListctrl);
	DDX_Control(pDX, IDC_EDIT1, m_ListDeviceInfoEdit);
}


BEGIN_MESSAGE_MAP(CPropPageSetting1, CPropertyPage)
	ON_NOTIFY(NM_DBLCLK, IDC_DEVICE_LIST, &CPropPageSetting1::OnNMDblclkDeviceList)
	ON_BN_CLICKED(IDC_DEVICEADD, &CPropPageSetting1::OnBnClickedDeviceadd)
	ON_BN_CLICKED(IDC_CHANGEFILE, &CPropPageSetting1::OnBnClickedChangefile)
//	ON_WM_ACTIVATE()
//ON_NOTIFY(LVN_ITEMCHANGED, IDC_DEVICE_LIST, &CPropPageSetting1::OnLvnItemchangedDeviceList)


ON_NOTIFY(LVN_ITEMCHANGED, IDC_DEVICE_LIST, &CPropPageSetting1::OnLvnItemchangedDeviceList)
ON_BN_CLICKED(IDC_DEVICESORT, &CPropPageSetting1::OnBnClickedDevicesort)
ON_BN_CLICKED(IDC_DEVICEDEL, &CPropPageSetting1::OnBnClickedDevicedel)

END_MESSAGE_MAP()


// CPropPageSetting1 消息处理程序


BOOL CPropPageSetting1::OnInitDialog()
{
	CPropertyPage::OnInitDialog();
	CMainFrame * pMainFrame = (CMainFrame *)AfxGetApp()->m_pMainWnd;
	
	CListCtrl* pmyListCtrl = (CListCtrl*)GetDlgItem(IDC_DEVICE_LIST);
	DWORD dwStyle = GetWindowLong(pmyListCtrl->m_hWnd, GWL_STYLE);
	SetWindowLong(pmyListCtrl->m_hWnd, GWL_STYLE, dwStyle | LVS_REPORT);

	//设置listctrl可以整行选择和网格条纹
	DWORD styles = pmyListCtrl->GetExtendedStyle();
	pmyListCtrl->SetExtendedStyle(styles | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

	//给listctrl设置5个标题栏
	TCHAR rgtsz[][12] = { _T("manufacture"), _T("device"), _T("package"), _T("mode"), _T("ISP") };

	//修改数组大小，可以确定分栏数和没栏长度，如果修改下面的数据（蓝色部分）也要跟着改变

	LV_COLUMN lvcolumn;
	CRect rect;
	pmyListCtrl->GetWindowRect(&rect);
	for (int i = 0; i < 5; i++)
	{
		lvcolumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT
			| LVCF_WIDTH | LVCF_ORDER;
		lvcolumn.fmt = LVCFMT_LEFT;
		lvcolumn.pszText = rgtsz[i];
		lvcolumn.iSubItem = i;
		lvcolumn.iOrder = i;
		lvcolumn.cx = rect.Width()/4;
		pmyListCtrl->InsertColumn(i, &lvcolumn);
	}
	if (0 == g_strCurJsonPath.IsEmpty())
	{
		
		ListCtrlShow();
	}
	pmyListCtrl->SetItemState(g_curDeviceSel,LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);

	TCHAR swztemp[MAX_PATH], swztemp1[MAX_PATH];
	wcscpy_s(swztemp, g_wszCurPath);
	wcscat_s(swztemp, L"setting.ini");
	GetPrivateProfileString(L"PATH", L"JFilePath", L"", swztemp1, MAX_PATH, swztemp);
	pMainFrame->m_strJsonPath = swztemp1;
	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常:  OCX 属性页应返回 FALSE
}


void CPropPageSetting1::OnNMDblclkDeviceList(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	// TODO:  在此添加控件通知处理程序代码
	NM_LISTVIEW *pNMListView = (NM_LISTVIEW *)pNMHDR;
	int nItem = pNMListView->iItem;
	m_nSelItem = nItem;
	CListCtrl* pmyListCtrl = (CListCtrl*)GetDlgItem(IDC_DEVICE_LIST);
	if (nItem >= 0 && nItem < pmyListCtrl->GetItemCount())//判断双击位置是否在有数据的列表项上面
	{
		CDeviceAddDla devdlg(this,nItem);
		if (IDOK == devdlg.DoModal())
		{
			ListCtrlShow();
		}
		pmyListCtrl->SetItemState(m_nSelItem, LVNI_FOCUSED | LVNI_SELECTED, LVNI_FOCUSED | LVNI_SELECTED);
		pmyListCtrl->SetFocus();
	}

	*pResult = 0;
}

//add
void CPropPageSetting1::OnBnClickedDeviceadd()
{
	CListCtrl *pListCtrl = (CListCtrl*)GetDlgItem(IDC_DEVICE_LIST);
	int nSelItem = pListCtrl->GetNextItem(-1, LVIS_SELECTED);
	if (nSelItem >= 0 && nSelItem < pListCtrl->GetItemCount())//判断双击位置是否在有数据的列表项上面
	{
		STU_DEVICE_INFO *newP = (STU_DEVICE_INFO*)realloc(pstuDevInfo, sizeof(STU_DEVICE_INFO)*(g_nDevInfoCnt + 1));
		if (NULL != newP)
		{
			pstuDevInfo = newP;
		}
		else
		{
			AfxMessageBox(L"pstuDevInfo realloc failed");
			return;
		}
		STU_SKT_NAME *newP1 = (STU_SKT_NAME*)realloc(pstusktname, sizeof(STU_SKT_NAME)*(g_nDevInfoCnt + 1));
		if (NULL != newP1)
		{
			pstusktname = newP1;
		
		}
		else
		{
			AfxMessageBox(L"pstusktname realloc failed");
			return;
		}
		pstusktname[g_nDevInfoCnt] = pstusktname[nSelItem];

		pstuDevInfo[g_nDevInfoCnt] = pstuDevInfo[nSelItem];
		
		strcat(pstuDevInfo[g_nDevInfoCnt].szDeviceName, "_");
		g_nDevInfoCnt++;
		ListCtrlShow();
		pListCtrl->EnsureVisible(g_nDevInfoCnt - 1, FALSE);
		pListCtrl->SetItemState(g_nDevInfoCnt-1, LVNI_FOCUSED | LVNI_SELECTED, LVNI_FOCUSED | LVNI_SELECTED);
		pListCtrl->SetFocus();
	}
	
	
}
void CPropPageSetting1::OnBnClickedDevicedel()
{
	int i;
	CListCtrl *pListCtrl = (CListCtrl*)GetDlgItem(IDC_DEVICE_LIST);
	int nSelItem = pListCtrl->GetNextItem(-1, LVIS_SELECTED);
	if (nSelItem >= 0 && nSelItem < pListCtrl->GetItemCount())//判断双击位置是否在有数据的列表项上面
	{
		//当前选中的栏目被之后的栏目一个个覆盖
		for (i = nSelItem; i < g_nDevInfoCnt-1; i++)
		{
			pstuDevInfo[i] = pstuDevInfo[i+1];
		}
		STU_DEVICE_INFO *newP = (STU_DEVICE_INFO*)realloc(pstuDevInfo, sizeof(STU_DEVICE_INFO)*(g_nDevInfoCnt -1));
		if (NULL != newP)
		{
			pstuDevInfo = newP;
		}
		else
		{
			AfxMessageBox(L"realloc failed");
			return;
		}
		for (i = nSelItem; i < g_nDevInfoCnt - 1; i++)
		{
			pstusktname[i] = pstusktname[i + 1];
		}
		STU_SKT_NAME *newP1 = (STU_SKT_NAME*)realloc(pstusktname, sizeof(STU_SKT_NAME)*(g_nDevInfoCnt - 1));
		if (NULL != newP1)
		{
			pstusktname = newP1;

		}
		else
		{
			AfxMessageBox(L"pstusktname realloc failed");
			return;
		}

		g_nDevInfoCnt--;
		ListCtrlShow();
		pListCtrl->EnsureVisible(nSelItem, FALSE);
		pListCtrl->SetItemState(nSelItem, LVNI_FOCUSED | LVNI_SELECTED, LVNI_FOCUSED | LVNI_SELECTED);
		pListCtrl->SetFocus();
	}
}

//change 然后选json文件,读出JSON文件内容
void CPropPageSetting1::OnBnClickedChangefile()
{
	CMainFrame *pMainframe = (CMainFrame *)AfxGetApp()->m_pMainWnd;
	
	CString defaultDir = pMainframe->m_strJsonPath,strTitle;
	//defaultDir = g_wszCurPath ;
	//defaultDir += L"lib";
	CString defaultFile = L"test1.txt";  
	CString filter = L"(*.j)|*.j|";
	CFileDialog openFileDlg(TRUE, NULL, defaultDir, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, NULL);
	INT_PTR result = openFileDlg.DoModal();
	if(result == IDOK)
	{
		//CString pathName, fileName, titleName, extName;
		CString pathName;
		pathName = openFileDlg.GetPathName();//得到完整的文件名，包括目录名和扩展名如：c:/test/test1.txt
		
// 		fileName = openFileDlg.GetFileName();//得到完整的文件名，包括扩展名如：test1.txt
		strTitle = openFileDlg.GetFileTitle();
		pMainframe->pSettingSheet->SetWindowTextW(strTitle);//得到完整的文件名，不包括目录名和扩展名如：test1
// 		extName = openFileDlg.GetFileExt();//
// 		MessageBox(pathName + "\r" + fileName + "\r" + titleName + "\r" + extName);//通过显示，注意几者区别
		pMainframe->m_strJsonPath = pathName;
		
		if (0 == ReadJson(pathName))
		{
			g_strCurJsonPath = pathName;
			ListCtrlShow();
		}
		TCHAR swzinipath[MAX_PATH];
		wcscpy_s(swzinipath, g_wszCurPath);
		wcscat_s(swzinipath, L"setting.ini");
		WritePrivateProfileString(L"Path", L"JFilePath", pathName, swzinipath);
	}
	
}


void CPropPageSetting1::ListCtrlShow()
{
	TCHAR wsztemp[400];
	
	int i;
	m_DevListctrl.DeleteAllItems();
	for (i = 0; i < g_nDevInfoCnt; i++)
	{
		CharToTchar(wsztemp, pstuDevInfo[i].szManufacture);
		m_DevListctrl.InsertItem(i, wsztemp);

		CharToTchar(wsztemp, pstuDevInfo[i].szDeviceName);
		m_DevListctrl.SetItemText(i, 1, wsztemp);
		CharToTchar(wsztemp, pstuDevInfo[i].szPackage);
		m_DevListctrl.SetItemText(i, 2, wsztemp);

		wsprintf(wsztemp, L"%d", pstuDevInfo[i].nAdapterMode);
		m_DevListctrl.SetItemText(i, 3, wsztemp);

		wsprintf(wsztemp, L"%d", pstuDevInfo[i].isIsp);
		m_DevListctrl.SetItemText(i, 4, wsztemp);
	}
}

void CPropPageSetting1::CreateCommaStrFromStr(char *des,char *src,int x,int y)
{
	int i;
	des[0] = 0;
	for (i = 0; i < x - 1; i++)
	{
		strcat(des, src + i*y);
		strcat(des, ",");
	}
	strcat(des, src + i*y);
}

void CPropPageSetting1::CreateCommaStrFromInt(char *des, int *src, int x)
{
	int i;
	char tmp[20];
	for (i = 0; i < x - 1; i++)
	{
		sprintf_s(tmp, "%d,", src[i]);
		strcat(des, tmp);
		
	}
	sprintf_s(tmp, "%d", src[i]);
	strcat(des, tmp);
}

void CPropPageSetting1::CreateCommaStrFromByte(char *des, char *src, int x)
{
	int i;
	char tmp[20];
	for (i = 0; i < x - 1; i++)
	{
		sprintf_s(tmp, "%d,", src[i]);
		strcat(des, tmp);

	}
	sprintf_s(tmp, "%d", src[i]);
	strcat(des, tmp);
}
void CPropPageSetting1::CreateCommaStrFromHex(char *des, int *src, int x)
{
	int i;
	char tmp[20];
	for (i = 0; i < x - 1; i++)
	{
		sprintf_s(tmp, "%x,", src[i]);
		strcat(des, tmp);

	}
	sprintf_s(tmp, "%x", src[i]);
	strcat(des, tmp);
}




int CPropPageSetting1::SaveJson()
{
	char sztemp[300];
	int j,i;

	Json::Reader reader;// 解析json用Json::Reade
	Json::Value root; // Json::Value是一种很重要的类型，可以代表任意类型。如int, string, object, array...         
	std::string code;

	std::ofstream os;
	Json::FastWriter write;
	Json::Value item;
	Json::Value array;
	
	for (j = 0; j < g_nDevInfoCnt; j++)
	{
		item["Manufacture"] = pstuDevInfo[j].szManufacture;
		item["Device"] = pstuDevInfo[j].szDeviceName;
		item["Package"] = pstuDevInfo[j].szPackage;
		item["AdapterMode"] = pstuDevInfo[j].nAdapterMode;
		item["Isp"] = pstuDevInfo[j].isIsp;
		item["nLoadFileUserDef"] = pstuDevInfo[j].nLoadFileUserDef;
		item["m_nReadConfirm"] = pstuDevInfo[j].m_nReadConfirm;
		item["nIsKeyAvailable"] = pstuDevInfo[j].nIsKeyAvailable;
		item["nIsEmmc"] = pstuDevInfo[j].nIsEmmc;
		item["nIsNeedHighZFPGA"] = pstuDevInfo[j].nIsNeedHighZFPGA;
		item["nIsNeedPinChk"] = pstuDevInfo[j].nIsNeedPinChk;
		item["Unit"] = pstuDevInfo[j].unit;
		item["ActualUnit"] = pstuDevInfo[j].wActualUnit;
		item["nLowVolAutoSense"] = pstuDevInfo[j].nLowVolAutoSense;
		item["BaseAddrEn"]= pstuDevInfo[j].wBaseAddrEn ;
		sztemp[0] = 0;
		

		sprintf(sztemp, "%s,%s,%s,%s", pstuDevInfo[j].szSocketName[0], pstuDevInfo[j].szSocketName[1], pstuDevInfo[j].szSocketName[2], pstuDevInfo[j].szSocketName[3]);
		item["Socket"] = sztemp;
		sprintf(sztemp, "%s,%s,%s,%s", pstusktname[j].szSocketNameClear[0], pstusktname[j].szSocketNameClear[1], pstusktname[j].szSocketNameClear[2], pstusktname[j].szSocketNameClear[3]);
		item["SocketClear"] = sztemp;

		sztemp[0] = 0;
		CreateCommaStrFromStr(sztemp, pstuDevInfo[j].szCID[0], 4, 4);
		item["Id"] = sztemp;
		item["Algo"] = pstuDevInfo[j].szAlgo;
		item["Fpga1"] = pstuDevInfo[j].szFpga0;
		item["Fpga2"] = pstuDevInfo[j].szFpga1;
		item["Fpga3"] = pstuDevInfo[j].szFpga2;
		item["Fpga4"] = pstuDevInfo[j].szFpga3;
		item["Config"] = pstuDevInfo[j].szConfig;
		item["Help"] = pstuDevInfo[j].szHelpName;
		sztemp[0] = 0;
		CreateCommaStrFromInt(sztemp, pstuDevInfo[j].nSignalPins, pstuDevInfo[j].nSignalPinCnt);
		item["Sigpins"] = sztemp;
		sztemp[0] = 0;
		CreateCommaStrFromInt(sztemp, pstuDevInfo[j].nVccPins, pstuDevInfo[j].nVccPinCnt);
		item["Vccpins"] = sztemp;
		sztemp[0] = 0;
		CreateCommaStrFromInt(sztemp, pstuDevInfo[j].nGndPins, pstuDevInfo[j].nGndPinCnt);
		item["Gndpins"] = sztemp;
		sztemp[0] = 0;
		CreateCommaStrFromStr(sztemp, pstuDevInfo[j].szVccs[0], 6, 6);
		item["Vcc"] = sztemp;
		sztemp[0] = 0;
		CreateCommaStrFromStr(sztemp, pstuDevInfo[j].szVccIOs[0], 3, 6);
		item["Vccio"] = sztemp;

		sztemp[0] = 0;
		CreateCommaStrFromInt(sztemp, pstuDevInfo[j].nParInts, 15);
		item["Parint"] = sztemp;

		sztemp[0] = 0;
		CreateCommaStrFromByte(sztemp, pstuDevInfo[j].cIsBufferHide, BUFNUM);
		item["cIsBufferHide"] = sztemp;

		sztemp[0] = 0;
		CreateCommaStrFromHex(sztemp, (int*)pstuDevInfo[j].nBufBaseAddr, BUFNUM);
		item["BufferBaseAddrs"] = sztemp;

		sztemp[0] = 0;
		CreateCommaStrFromInt(sztemp, pstuDevInfo[j].nProgDllpara, 2);
		item["nProgDllpara"] = sztemp;

		

		sztemp[0] = 0;
		CreateCommaStrFromStr(sztemp, pstuDevInfo[j].szParIntNameArrs[0], 15, 20);
		item["ParNames"] = sztemp;
		sztemp[0] = 0;
		CreateCommaStrFromStr(sztemp, pstuDevInfo[j].szBufNameArrs[0], BUFNUM, 30);
		item["BufferNames"] = sztemp;
		CreateCommaStrFromStr(sztemp, pstuDevInfo[j].szBufSizeArrs[0], BUFNUM, 30);
		item["BufferSizes"] = sztemp;
		CreateCommaStrFromStr(sztemp, pstuDevInfo[j].szBufValueArrs[0], BUFNUM, 5);
		item["BufferValues"] = sztemp;
		sprintf_s(sztemp, "%x", pstuDevInfo[j].nFitNess);
		item["FitNess"] = sztemp;

		sztemp[0] = 0;
		if (pstuDevInfo[j].wDftAutCnt > 16)
		{
			for (i = 0; i < pstuDevInfo[j].wDftAutCnt; i++)
			{
				if(i<16)
					sprintf(sztemp + strlen(sztemp), "%x,", pstuDevInfo[j].cDftAutCntArr[i]);
				else
					sprintf(sztemp + strlen(sztemp), "%x,", pstuDevInfo[j].cDftAutCntArr1[i-16]);
			}
		}
		else
		{
			for (i = 0; i < pstuDevInfo[j].wDftAutCnt; i++)
			{
				sprintf(sztemp + strlen(sztemp), "%x", pstuDevInfo[j].cDftAutCntArr[i]);
			}
		}
		
		item["DftAuto"] = sztemp;
		item["DllName"] = pstuDevInfo[j].szProgDllName;
		item["DllLdFileName"] = pstuDevInfo[j].szLdFileDllName;
		item["DllChksumFileName"] = pstuDevInfo[j].szChecksumDllName;

		sztemp[0] = 0;
		CreateCommaStrFromByte(sztemp, pstuDevInfo[j].cAisAutoLoadBuf, sizeof(pstuDevInfo[j].cAisAutoLoadBuf));
		item["cAisAutoLoadBuf"] = sztemp;

		sztemp[0] = 0;
		CreateCommaStrFromByte(sztemp, pstuDevInfo[j].cIsBufOTP, sizeof(pstuDevInfo[j].cIsBufOTP));
		item["cIsBufOTP"] = sztemp;

		array.append(item);
	}


	//每个芯片的细节


	//根
	root["device"] = array;

	//string str = root.toStyledString();
	string str = write.write(root);


	std::ofstream ofss;
	ofss.open(g_strCurJsonPath);
	ofss << str;
	ofss.close();
	return 0;
}




void CPropPageSetting1::OnLvnItemchangedDeviceList(NMHDR *pNMHDR, LRESULT *pResult)
{
	int i;
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
	CString strShow;
	CString strtmp;
	char  sztemp[200];
	TCHAR wsztemp[200];
	if (pNMLV->uChanged == LVIF_STATE)
	{
		if (pNMLV->uNewState)
		{
			int nIndex = pNMLV->iItem;

			strShow += L"Device:";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szDeviceName);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"Manufacture:";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szManufacture);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"Package:";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szPackage);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow  += L"Adaptor Mode:";
			strtmp.Format(L"%d\r\n", pstuDevInfo[nIndex].nAdapterMode);
			strShow += strtmp;

			strShow += L"CID:";
			sprintf(sztemp, "%s,%s,%s,%s", pstuDevInfo[nIndex].szCID[0], pstuDevInfo[nIndex].szCID[1], pstuDevInfo[nIndex].szCID[2], pstuDevInfo[nIndex].szCID[3]);
			CharToTchar(wsztemp, sztemp);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"Algo:";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szAlgo);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"DftAuto:";
			for (i = 0; i < pstuDevInfo[nIndex].wDftAutCnt; i++)
			{
				strShow.AppendFormat(L"%x", pstuDevInfo[nIndex].cDftAutCntArr[i]);
			}
			strShow += L"\r\n";

			strShow += L"Key:";				
			strShow.AppendFormat(L"%x", pstuDevInfo[nIndex].nIsKeyAvailable);	
			strShow += L"\r\n";

			strShow += L"Key:";
			strShow.AppendFormat(L"%x", pstuDevInfo[nIndex].nIsEmmc);
			strShow += L"\r\n";

			strShow += L"nIsNeedHighZFPGA:";
			strShow.AppendFormat(L"%x", pstuDevInfo[nIndex].nIsNeedHighZFPGA);
			strShow += L"\r\n";

			strShow += L"PinCheck:";
			strShow.AppendFormat(L"%x", pstuDevInfo[nIndex].nIsNeedPinChk);
			strShow += L"\r\n";

			strShow += L"Fpga0:";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szFpga0);
			strShow += wsztemp;
			strShow += L",";

			strShow += L"Fpga1:";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szFpga1);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"Config:";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szConfig);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"Help:";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szHelpName);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"PinCheck:";
			strtmp.Format(L"%d\r\n", pstuDevInfo[nIndex].nIsNeedPinChk);
			strShow += strtmp;

			strShow += L"HIGHZFPGA:";
			strtmp.Format(L"%d\r\n", pstuDevInfo[nIndex].nIsNeedHighZFPGA);
			strShow += strtmp;

			strShow += L"BufferName:";
			wsztemp[0] = 0;
			for (i = 0; i < sizeof(pstuDevInfo[nIndex].szBufNameArrs) / sizeof(pstuDevInfo[nIndex].szBufNameArrs[0]); i++)
			{
				CharToTchar(wsztemp+wcslen(wsztemp), pstuDevInfo[nIndex].szBufNameArrs[i]);
				wcscat(wsztemp, L",");
			}
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"BufferSize:";
			wsztemp[0] = 0;
			for (i = 0; i < sizeof(pstuDevInfo[nIndex].szBufSizeArrs) / sizeof(pstuDevInfo[nIndex].szBufSizeArrs[0]); i++)
			{
				CharToTchar(wsztemp + wcslen(wsztemp), pstuDevInfo[nIndex].szBufSizeArrs[i]);
				wcscat(wsztemp, L",");
			}
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"BufferValue:";
			wsztemp[0] = 0;
			for (i = 0; i < sizeof(pstuDevInfo[nIndex].szBufValueArrs) / sizeof(pstuDevInfo[nIndex].szBufValueArrs[0]); i++)
			{
				CharToTchar(wsztemp + wcslen(wsztemp), pstuDevInfo[nIndex].szBufValueArrs[i]);
				wcscat(wsztemp, L",");
			}
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"IntValue:";
			wsztemp[0] = 0;
			for (i = 0; i < sizeof(pstuDevInfo[nIndex].nParInts) / sizeof(pstuDevInfo[nIndex].nParInts[0]); i++)
			{
				wsprintf(wsztemp + wcslen(wsztemp), L"%d,", pstuDevInfo[nIndex].nParInts[i]);
				//wcscat(wsztemp, L",");
			}
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"SocketNameClear:";
			wsztemp[0] = 0;
			for (i = 0; i < sizeof(pstuDevInfo[nIndex].szSocketName) / sizeof(pstuDevInfo[nIndex].szSocketName[0]); i++)
			{
				CharToTchar(wsztemp + wcslen(wsztemp), pstusktname[nIndex].szSocketNameClear[i]);
				wcscat(wsztemp, L",");
			}
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"DllName(prog):";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szProgDllName);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"DllName(loadfile):";
			CharToTchar(wsztemp , pstuDevInfo[nIndex].szLdFileDllName);
			strShow += wsztemp;
			strShow += L"\r\n";

			strShow += L"DllName(Checksum):";
			CharToTchar(wsztemp, pstuDevInfo[nIndex].szChecksumDllName);
			strShow += wsztemp;
			strShow += L"\r\n";



			
			m_ListDeviceInfoEdit.SetWindowTextW(strShow);
			//GetDlgItem(IDC_EDIT_MAN)->SetWindowText(wsztemp);
			

		}

	}
	*pResult = 0;
}



void CPropPageSetting1::OnBnClickedDevicesort()
{
	// TODO:  在此添加控件通知处理程序代码
}




